//
//  DEWRingPeopleViewController.m
//  OtherDemo
//
//  Created by kangbinbin on 2018/7/29.
//  Copyright © 2018年 lianjie. All rights reserved.
//

#import "DEWRingPeopleViewController.h"
#import "DEWRingPeopeleCell.h"
#import "FDActionSheet.h"
#import "DEWApplyForView.h"

static NSString *const cellID = @"ringpeople";


@interface DEWRingPeopleViewController ()<UITableViewDataSource,UITableViewDelegate>
/** <#type#> */
@property (strong, nonatomic) UITableView *tableView;
/** 分享View */
@property (strong, nonatomic) FDActionSheet *sheet;

@end

@implementation DEWRingPeopleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadData];
    
    [self createView];
    
}

#pragma mark ----RequestData
-(void)loadData
{
    
    
}

#pragma mark ----initView
-(void)createView
{
    self.navigationItem.title = @"我的圈子";
    
    [self creatTab];
    
}
-(void)creatTab{

    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, DEWScreenWidth , DEWScreenHeight - NAVH) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
    if (@available(iOS 11.0, *)){
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        self.tableView.estimatedRowHeight = 0;
        self.tableView.estimatedSectionHeaderHeight = 0;
        self.tableView.estimatedSectionFooterHeight = 0;
    }
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([DEWRingPeopeleCell class]) bundle:nil] forCellReuseIdentifier:cellID];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 2;
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        DEWRingPeopeleCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
        
        return cell;
    }else{
        NSString *cellID = [NSString stringWithFormat:@"12%ld%ld",(long)indexPath.section,(long)indexPath.row];
        UITableViewCell *cell = nil;
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
       
        UIButton *ShenQBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        ShenQBtn.frame = CGRectMake(DEWScreenWidth / 2 - 50, 10, 100, 25);
        [ShenQBtn setTitle:@"申请为管理员" forState:UIControlStateNormal];
        [ShenQBtn setBackgroundColor:UIColorFromRGB(0xFF8900)];
        [ShenQBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [ShenQBtn addTarget:self action:@selector(shequBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [cell addSubview:ShenQBtn];
        
        return cell;
        
    }

}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0 ) {
        return 90;
    }else{
         return 50;
    }
   
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 40;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DEWScreenWidth , 40)];
    headerView.backgroundColor = [UIColor whiteColor];
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
    imageView.image = [UIImage imageNamed:@"圈主、管理员"];
    [headerView addSubview:imageView];
    
    UILabel *label = [[UILabel alloc]init];
    label.frame = CGRectMake(40, 10, DEWScreenWidth - 50, 20);
    label.text = @"圈主、管理员 (1)";
    label.textColor = Color_33;
    label.font = [UIFont boldSystemFontOfSize:14];
    [headerView addSubview:label];
    
    return headerView;
}
#pragma mark - 申请成为管理员按钮点击时间
-(void)shequBtnClick:(UIButton *)sender{
    
    [DEWApplyForView showApplyForViewpushbtnBlock:^(NSString *str) {
        NSLog(@"%@",str);
    }];
    
}
//-(FDActionSheet *)sheet{
//    if (_sheet == nil) {
//        _sheet = [[FDActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"收藏",@"分享",@"举报", nil];
//        _sheet.delegate = self;
//    }
//    return _sheet;
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
